package org.example.JVM.ByteCode.Type.CONSTANT;

import org.example.JVM.ByteCode.Type.CpInfo;
import org.example.JVM.ByteCode.Type.U1;
import org.example.JVM.ByteCode.Type.U4;

import java.nio.ByteBuffer;

/**
 * @description:
 * @author: farprt
 * @create: 2022-11-13 15:42
 **/
public class CONSTANT_Integer_info extends CpInfo {

    private U4 bytes;

    public CONSTANT_Integer_info(U1 tag) {
        super(tag);
    }

    @Override
    public void read(ByteBuffer codeBuf) throws Exception {
        bytes = new U4(codeBuf.get(), codeBuf.get(), codeBuf.get(), codeBuf.get());
    }

    @Override
    public String toString() {
        return super.toString() + ",value=" + bytes.toInt();
    }
}